###
  日期：2013-12-06
  作者：胡纬
  描述：用来进行图片的处理
###


resize = require('../services/resize').resize
resErr = require('./util').resErr
util = require("util")

exports.img_resize = (req,res) ->
  return resErr(res,'filename不得为空')  unless req.param('filename')
  return resErr(res,'width不得为空') unless req.param('width')
  return resErr(res,'srcfile不得为空') unless req.param('srcfile')
  resize req.param('srcfile'),req.param('width'),req.param('filename'),(err,data) ->
    if err
      resErr res,err
    else
      res.json(data)